<template>
  <div>
    <el-card  shadow='false' class="box-card">
      <div slot="header" class="clearfix">
        <span>注册用户列表</span>
      </div>
      <div class="text item">
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column align="center" type="index" label="序号" width="50">
          </el-table-column>
          <el-table-column
            align="center"
            prop="username"
            label="用户名"
          ></el-table-column>
          <el-table-column align="center" prop="name" label="头像">
            <template slot-scope="scope">
              <!-- <el-image
                style="width: 60px; height: 60px; border-radius: 50%"
                :src="scope.row.icon"
              ></el-image> -->
              <el-avatar
                style="width: 60px; height: 60px"
                size="large"
                :src="scope.row.icon"
              ></el-avatar>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="nickname" label="昵称">
          </el-table-column>
          <el-table-column align="center" prop="realname" label="真实姓名">
          </el-table-column>
          <el-table-column align="center" prop="" label="性别">
            <template slot-scope="scope">
              <p>{{ scope.row.sex == 0 ? "男" : "女" }}</p>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="phone" label="电话">
          </el-table-column>
          <el-table-column align="center" prop="email" label="邮箱">
          </el-table-column>
          <el-table-column align="center" prop="birthday" label="生日">
          </el-table-column>
          <el-table-column align="center" prop="createTime" label="注册时间">
          </el-table-column>
        </el-table>
      </div>

      <pagination
        @limitfather="limitchange"
        @startfather="startchange"
        :totalNumber="totalnumber"
      ></pagination>
    </el-card>
  </div>
</template>

<script>
import pagination from "@/components/common/pagination";
import userApi from "@/api/user/index";
export default {
  components: { pagination },

  data() {
    return {
      start: 1,
      limit: 10,
      tableData: [],
      totalnumber: 0,
    };
  },

  created() {
    this.init();
  },

  mounted() {},

  methods: {
    // 来自子组件切换limit
    limitchange(e) {
      console.log(e);
      this.limit = e;
      this.init();
    },
    // 来自子组件切换start
    startchange(e) {
      console.log(e);
      this.start = e;
      this.init();
    },
    // 获取用户列表
    init() {
      userApi.findMembersByPage(this.start, this.limit).then((res) => {
        console.log(res);
        this.tableData = res.data.rows;
        this.totalnumber = res.data.total;
      });
    },
    // 切换每页显示多少个
    handleSizeChange(e) {
      console.log(e);
      this.limit = e;
      this.init();
    },
    // 切换页码
    handleCurrentChange(e) {
      console.log(e);
      this.start = e;
      this.init();
    },
  },

  computed: {},

  watch: {},
};
</script>

<style scoped lang='scss'>
.box-card {
  width: 97%;
  margin: 15px auto;
}
</style>